    <div class="container">
      <div class="bg-putih">

        <div class="jdl-page">
          <?php echo isset($judul)?$judul:'<font color="#ccc">Judul Belum Diberikan</font>'; ?>
          <div class="clearfix"></div>
        </div>
        
        <?php echo display_flash(); ?>
        <?php $filter = $this->session->userdata('filter');
        $keyword = $this->session->userdata('keyword_kunjungan');
        ?>

        <div class="row">
          <div class="col-xs-6">
            <div class="btn-group btn-group-sm" role="group">
              <a href="<?php echo site_url('pasien_kunjungan/add'); ?>" class="btn btn-primary"><i class="fa fa-plus"></i>&nbsp;Tambah</a>
              <?php if($this->uri->segment(2) == "search"): ?>
                <a href="<?php echo site_url("pasien_kunjungan/excel/$filter/$keyword"); ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i>&nbsp;Unduh Excel</a>
              <?php elseif($this->uri->segment(2) == ""): ?>
                <a href="<?php echo site_url('pasien_kunjungan/excel'); ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i>&nbsp;Unduh Excel</a>
              <?php endif; ?>
            </div>
          </div>
          <div class="col-xs-6">
            <?php echo form_open('pasien_kunjungan/search'); ?>
            <div id="input-grp" class="input-group-3">              
              <button type="submit" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-search"></span></button>
              <select name="filter" class="form-control input-sm" onchange="change_filter(this.value)">
                <?php if($filter == 'by_name'): ?>
                  <option value="by_name" selected="selected">Nama</option>
                <?php else: ?>
                  <option value="by_name">Nama</option>
                <?php endif; ?>
                
                <?php if($filter == 'by_code'): ?>
                  <option value="by_code" selected="selected">Kode</option>
                <?php else: ?>
                  <option value="by_code">Kode</option>
                <?php endif; ?>

                <?php if($filter == 'by_keluhan'): ?>
                  <option value="by_keluhan" selected="selected">Keluhan</option>
                <?php else: ?>
                  <option value="by_keluhan">Keluhan</option>
                <?php endif; ?>

                <?php if($filter == 'by_waktu'): ?>
                  <option value="by_waktu" selected="selected">Waktu</option>
                <?php else: ?>
                  <option value="by_waktu">Waktu</option>
                <?php endif; ?>
              </select>
              <span id="inpt-cont" style="display:block">
                <input type="text" class="form-control input-sm" style="width:100%" name="keyword" placeholder="Cari kunjungan"/>
              </span>
            </div>
            <?php echo form_close(); ?>
            <script type="text/javascript">
              function change_filter(filter){
                if(filter == "by_waktu"){
                  $("#inpt-cont").html("");
                  var  html_code = '<input type="text" placeholder="Akhir . . . ." style="border-radius: 0px;margin-left:-1px;" name="waktu_akhir" class="form-control input-sm" id="waktu_akhir" /><input type="text"  style="border-radius: 5px 0px 0px 5px;" placeholder="Awal . . ." name="waktu_awal" class="form-control input-sm" id="waktu_awal"/>';
                  $("#inpt-cont").html(html_code);
                  $("#waktu_awal, #waktu_akhir").datepicker({
                    dateFormat: "yy-mm-dd",
                    changeMonth: true,
                    changeYear: true
                  });
                }else{
                  var html_code = '<input type="text" class="form-control input-sm" style="width:100%" name="keyword" placeholder="Cari kunjungan"/>';
                  $("#inpt-cont").html(html_code);
                }
              }
            </script>
          </div>
        </div>

        <table class="table table-striped table-hover margintop20">
          <thead>
            <tr>
              <th width="3%" style="text-align:center;">No</th>
              <th width="15%" style="text-align:left;">Kode Kunjungan</th>
              <th width="15%" style="text-align:left;">Nama Pasien</th>
              <th width="15%" style="text-align:left;">Tanggal</th>
              <th width="5%" style="text-align:left;">TD</th>
              <th width="5%" style="text-align:left;">Suhu</th>
              <th width="5%" style="text-align:left;">RR</th>
              <th width="5%" style="text-align:left;">HR</th>
              <th style="text-align:left;">Keluhan</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            if(!empty($results)){
              foreach ($results as $row) {
                ?>
                <tr>
                  <td align="center"><?php echo $ordinal_num++ ?></td>
                  <td><?php echo $row['KdKunjungan']?></td>
                  <td><?php echo $row['Nama']?></td>
                  <td>
                    <?php echo id_date($row['Tanggal'],'long')?>
                  </td>
                  <td><?php echo $row['TD']?></td>
                  <td><?php echo $row['Suhu']?></td>
                  <td><?php echo $row['RR']?></td>
                  <td><?php echo $row['HR']?></td>
                  <td>
                    <?php echo trim_text($row['Keluhan'],15)?>
                    <span class="pull-right">
                      <a href="<?php echo site_url('pasien_kunjungan/edit/' . $row['KdKunjungan']) ?>" class="label label-success" title="Edit">Edit</a>
                      <a href="<?php echo site_url('pasien_kunjungan/delete/' . $row['KdKunjungan']) ?>" class="label label-default" title="Hapus" onClick="return confirm('Yakin ingin menghapus <?php echo $row['Nama']?> ?')">Hapus</a>
                    </span>
                  </td>

                </tr>
                <?php 
              }
            }else{
              ?>
              <tr>
                <td colspan="9" align="center">Tidak ada data</td>
              </tr>
              <?php
            }
            ?>
          </tbody>
        </table>

        <center style="margin-top:-30px;">
          <ul class="pagination">
            <?php echo $pagination; ?>
          </ul>
        </center>

        <div class="clearfix"></div>
      </div>
    </div> <!-- /container -->